<!--
 * @Author: your name
 * @Date: 2021-10-01 15:10:11
 * @LastEditTime: 2021-10-01 15:15:37
 * @LastEditors: your name
 * @Description: In User Settings Edit
 * @FilePath: \1-ej-web\src\components\PhoneChart\index.vue
-->
<script>
export default {
  props: ['data'],
  data() {
    return {}
  },
  mounted() {
    this.init()
  },
  methods: {
    init() {
      // 初始化表格
      const main_chart = document.getElementById('main_chart')
      main_chart.style.height = '420px'
      // eslint-disable-next-line no-undef
      var myChart = echarts.init(main_chart)
      // 使用刚指定的配置项和数据显示图表。
      myChart.setOption({
        tooltip: {},
        legend: {
          data: ['价格']
        },
        xAxis: {
          type: 'category',
          data: this.data.dates
        },
        yAxis: {
          type: 'value'
        },
        series: [{
          data: this.data.prices,
          type: 'line'
        }]
      })
    }
  },
  render(createElement) {
    return createElement('div', {
      attrs: {
        id: 'main_chart'
      }
    })
  }
}
</script>
